package main

import (
	"context"
	"fmt"
	"gorm.io/gen"
	"main/web_test/config"
	"main/web_test/query"
)

func main() {
	config.InitMysql()
	q := query.Use(config.DB)

	ctx := context.Background()

	user, _ := q.User.WithContext(ctx).Limit(10).Offset(0).Find()

	fmt.Println(user)

	for _, v := range user {
		fmt.Println(v)
	}

	//generate()

}

func generate() {
	generator := gen.NewGenerator(gen.Config{
		OutPath:      "web_test/query",
		ModelPkgPath: "query/model",
		Mode:         gen.WithDefaultQuery | gen.WithQueryInterface,
	})

	config.InitMysql()

	generator.UseDB(config.DB)

	generator.ApplyBasic(generator.GenerateAllTable()...)

	generator.Execute()
}
